﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponents.Design.Attributes;
using DevExpress.XtraEditors;
using System.ComponentModel;
using DevExpress.XtraTreeList;
using DevExpress.XtraGrid.Views.Base;
using ProgNetComponents.ExtenderProviders;

namespace ProgNetDxComponents.ExtenderProviders.Settings
{
    public class LayoutSettings : ProgNetComponents.ExtenderProviders.Settings.BaseExtenderSettings
    {
        public LayoutSettings(object Owner, BaseExtenderProvider provider) : base(Owner, provider)
        {

        }
        private bool _SaveLayout = true;
        private SplitContainerLayoutProperties _SplitContainerLayoutProperties = new SplitContainerLayoutProperties();
        private TreeListLayoutProperties _TreeListLayoutProperties = new TreeListLayoutProperties();
        private GridCtrlLayoutProperties _GridCtrlLayoutProperties = new GridCtrlLayoutProperties();

        [RefreshProperties(System.ComponentModel.RefreshProperties.All)]
        public bool SaveLayout
        {
            get { return _SaveLayout; }
            set
            {
                _SaveLayout = value;
                OnSettingsChanged();
            }
        }
        
        [DynamicBrowsableByProperty("SaveLayout", true),
        DynamicBrowsableByType("Owner", typeof(SplitContainerControl)),
        DisplayName("Layout Properties"),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public SplitContainerLayoutProperties SplitContainerLayoutProperties
        {
            get { return _SplitContainerLayoutProperties; }
        }

        [DynamicBrowsableByProperty("SaveLayout", true), 
        DynamicBrowsableByType("Owner", typeof(TreeList)),
        DisplayName("Layout Properties"),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public TreeListLayoutProperties TreeListLayoutProperties
        {
            get { return _TreeListLayoutProperties; }
        }

        [DynamicBrowsableByProperty("SaveLayout", true), 
        DynamicBrowsableByType("Owner", typeof(ColumnView)),
        DisplayName("Layout Properties"),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public GridCtrlLayoutProperties GridCtrlLayoutProperties
        {
            get { return _GridCtrlLayoutProperties; }
        }
    }

    public class SplitContainerLayoutProperties
    {
        #region MEMBERS
        private bool _StoreSplitterPosition = true;
        private bool _StoreCollapsePanel = true;
        private bool _StorePanelVisibility = true;
        #endregion

        #region PROPERTIES
        public bool StoreSplitterPosition
        {
            get { return _StoreSplitterPosition; }
            set { _StoreSplitterPosition = value; }
        }
        public bool StoreCollapsePanel
        {
            get { return _StoreCollapsePanel; }
            set { _StoreCollapsePanel = value; }
        }
        public bool StorePanelVisibility
        {
            get { return _StorePanelVisibility; }
            set { _StorePanelVisibility = value; }
        }
        #endregion
    }
    public class TreeListLayoutProperties
    {
        #region MEMBERS
        private bool storeColumnWidth = true;
        private bool storeColumnVisible = true;
        private bool storeColumnVisibleIndex = true;
        private bool storeColumnSortOrder = true;
        private bool storeRowHeight = true;
        private bool storeColumnFreeze = true;
        #endregion

        #region PROPERTIES
        public bool StoreColumnWidth
        {
            get { return storeColumnWidth; }
            set { storeColumnWidth = value; }
        }

        public bool StoreColumnVisible
        {
            get { return storeColumnVisible; }
            set { storeColumnVisible = value; }
        }

        public bool StoreColumnVisibleIndex
        {
            get { return storeColumnVisibleIndex; }
            set { storeColumnVisibleIndex = value; }
        }

        public bool StoreColumnSortOrder
        {
            get { return storeColumnSortOrder; }
            set { storeColumnSortOrder = value; }
        }

        public bool StoreRowHeight
        {
            get { return storeRowHeight; }
            set { storeRowHeight = value; }
        }

        public bool StoreColumnFreeze
        {
            get { return storeColumnFreeze; }
            set { storeColumnFreeze = value; }
        }
        #endregion
    }
    public class GridCtrlLayoutProperties
    {
        #region MEMBERS
        private bool storeColumnWidth = true;
        private bool storeColumnVisible = true;
        private bool storeColumnVisibleIndex = true;
        private bool storeColumnSortOrder = true;
        private bool storeColumnFilterInfo = true;
        private bool storeViewRowHeight = true;
        private bool storeColumnFreeze = true;
        private bool storeColumnCaption = false;
        private bool storeGroupPanelSettings = true;
        #endregion

        #region PROPERTIES
        public bool StoreColumnWidth
        {
            get { return storeColumnWidth; }
            set { storeColumnWidth = value; }
        }

        public bool StoreColumnVisible
        {
            get { return storeColumnVisible; }
            set { storeColumnVisible = value; }
        }

        public bool StoreColumnVisibleIndex
        {
            get { return storeColumnVisibleIndex; }
            set { storeColumnVisibleIndex = value; }
        }

        public bool StoreColumnSortOrder
        {
            get { return storeColumnSortOrder; }
            set { storeColumnSortOrder = value; }
        }

        public bool StoreColumnFilterInfo
        {
            get { return storeColumnFilterInfo; }
            set { storeColumnFilterInfo = value; }
        }

        public bool StoreViewRowHeight
        {
            get { return storeViewRowHeight; }
            set { storeViewRowHeight = value; }
        }

        public bool StoreColumnFreeze
        {
            get { return storeColumnFreeze; }
            set { storeColumnFreeze = value; }
        }

        public bool StoreColumnCaption
        {
            get { return storeColumnCaption; }
            set { storeColumnCaption = value; }
        }

        public bool StoreGroupPanelSettings
        {
            get { return storeGroupPanelSettings; }
            set { storeGroupPanelSettings = value; }
        }
        #endregion
    }
}
